package ace.module.captcha.sms.core.impl.controller.rest.rpc;

import ace.cmp.core.model.R;
import ace.cmp.security.oauth2.resource.server.core.annotation.PreAuthorizeIsInternalClient;
import ace.module.captcha.sms.core.impl.service.CaptchaSmsService;
import ace.module.captcha.sms.sdk.core.feign.impl.CaptchaSmsFeign;
import ace.module.common.api.annotation.ApiRemoteImplementPriority;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Caspar rpc 入口
 */
@Tag(name = "短信验证码服务-RPC-API")
@AllArgsConstructor
@RestController
@RequestMapping(CaptchaSmsFeign.PATH)
@PreAuthorizeIsInternalClient
@ApiRemoteImplementPriority
public class CaptchaSmsRpcController implements CaptchaSmsFeign {

  private final CaptchaSmsService captchaSmsService;

  @Override
  public R<String> send(Long captchaSmsAppId, String phoneNumber, String code) {
    return this.captchaSmsService.send(captchaSmsAppId, phoneNumber, code);
  }

  @Override
  public R<Void> verify(Long captchaSmsAppId, String phoneNumber, String code) {
    return this.captchaSmsService.verify(captchaSmsAppId, phoneNumber, code);
  }

  @Override
  public R<Void> verify(String captchaSmsAppKey, String phoneNumber, String code) {
    return this.captchaSmsService.verify(captchaSmsAppKey, phoneNumber, code);
  }
}
